/*
 * ConceptInfoContainer.java
 *
 * Created on 28 March 2007, 18:44
 *
 */

package rxtokenizer;

import java.util.*;

/**
 *
 * @author Ruslan Fayzrakhmanov
 */
public class ConceptTypeContainer {
    
    public ConceptTypeContainer() {
	conceptTypes = new LinkedList();
    }
    
    public ConceptTypeContainer(LinkedList conceptTypes) {
	this.conceptTypes = conceptTypes;
    }
    
    public ConceptType getConceptTypeByName(String name) {
        name = name.toLowerCase();
        ConceptType conceptType = null;
        Iterator conceptTypeIter = conceptTypes.iterator();
        while ( (conceptType == null) && (conceptTypeIter.hasNext()) ) {
            conceptType = (ConceptType)conceptTypeIter.next();
            if (name.compareTo(conceptType.name.toLowerCase())!=0) conceptType = null;
        }
        return conceptType;
    }
    
    public void addUniqueConceptType(ConceptType conceptType) {
	ConceptType conceptType2 = getConceptTypeByName(conceptType.name);
	if (conceptType2 == null) conceptTypes.add(conceptType);
    }
    
    public LinkedList getConceptTypes() {
        return conceptTypes;
    }
    
    public String toString() {
	StringBuffer str = new StringBuffer();
	Iterator conceptTypeIter = conceptTypes.iterator();
	int i=1;
        while (conceptTypeIter.hasNext()) {
	    str.append(i++ + ":\n");
             str.append(conceptTypeIter.next());
	}
	return str.toString();
    }
    
    LinkedList conceptTypes; // !=null (forever)
    
}
